package com.wenbo.wenbo.controller;


import com.wenbo.wenbo.dto.UserInfoDto;
import com.wenbo.wenbo.service.WeChatService;
import com.wenbo.wenbo.utils.ResultObject;
import com.wenbo.wenbo.utils.WeChatUtil;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * @author ywb
 * @date 2021年12月23日 9:07
 */
@RestController
@RequestMapping("/api/wechat")
public class WeChatController {

    @Resource
    private WeChatService weChatService;

    /**
     *获取用户openId
     * @param code
     */
    @RequestMapping("/getOpenId")
    public ResultObject<String> getOpenId(String code){
        return ResultObject.ok("查询成功").setData(weChatService.getOpenId(code));
    }

    /**
     *获取用户openId
     * @param userInfo
     */
    @PostMapping("/saveUserInfo")
    public void saveUserInfo(@RequestBody UserInfoDto userInfo){
        weChatService.saveUserInfo(userInfo);
    }


}
